<template>
  <div>
    <h1>这是首页</h1>
    <router-link to="/news">到新闻页</router-link>
    <hr>
    items模块中的num:
    <!-- {{ $store.state.items.num }} -->
    <button @click="addNum">itemNum的+</button>
    {{ itemNum }}
    <br>
    order模块中的num
    <!-- {{ $store.state.order.num }} -->
    {{ orderNum }}
  </div>
</template>

<script>
import { mapState, mapMutations } from 'vuex'
export default {
  name: 'Home',
  methods: {
    addNum () {
      // this['items/add_num'](100)
      this.add_num(50)
    },
    // ...mapMutations(['items/add_num', 'order/add_num'])
    ...mapMutations('items', ['add_num'])
  },
  computed: {
    ...mapState({
      itemNum: state => state.items.num,
      orderNum: state => state.order.num
    })
  }
}
</script>

<style lang="scss" scoped>

</style>
